package com.tmxk.employee.utils;

import java.text.DecimalFormat;
import java.util.Random;

/**
 * 获取指定位数随机验证码
 */
public class RandomNumberUtils {
    //代码补零(四位数)
    static DecimalFormat dfFour = new DecimalFormat("0000");
    //代码补零(六位数)
    static DecimalFormat dfSix = new DecimalFormat("000000");

    //随机获取四位数
    public static String getFourNum(){
        int four = new Random().nextInt(10000);
        return dfFour.format(four);
    }

    //随机获取六位数
    public static String getSixNum(){
        int six = new Random().nextInt(1000000);
        return dfSix.format(six);
    }

    public static void main(String[] args) {

        for (int i = 0; i < 10 ; i++) {
            Thread t = new Thread();
            t.start();
            System.out.println(getFourNum());
        }
    }

    //随机获取六位数
}
